# 输入晶胞尺寸，摩尔浓度，密度，得到分子个数

NA = 6.02214076*10**23
M_anion = 35.453
M_caion = 22.990
M_H2O = 18.015

def a2cm(n):
    return float(n)*10**(-8)

def calMoleculeNum(dim, C_anion, C_caion, density):
    # dim = [a, b, c]/(A, A, A)
    # C_anion 阴离子浓度/(mol/L)
    # C_caion 阳离子浓度/(mol/L)
    # density 溶液密度/(g/cm^3)，用于计算水分子个数
    # return [N_H2O, N_anion, N_caion]

    a = a2cm(dim[0]) # /(cm)
    b = a2cm(dim[1]) # /(cm)
    c = a2cm(dim[2]) # /(cm)

    V = a * b * c # 晶胞体积/(cm^3)

    # (mol/L) -> (mol/mL)
    C_anion = C_anion / 1000
    C_caion = C_caion / 1000

    m_H2O = density * V #ρ = m * V
    N_H2O = (m_H2O / M_H2O) * NA
    N_anion = C_anion * V * NA
    N_caion = C_caion * V * NA

    return [N_H2O, N_anion, N_caion]



while True:
    a = input("Please Input Lattice size: (a)")
    b = input("Please Input Lattice size: (b)")
    c = input("Please Input Lattice size: (c)")
    c1 = input("Please Input Concentration of anion: (c1)")
    c2 = input("Please Input Concentration of caion: (c2)")
    density = input("Please Input Density of sulotion: (density)")

    print(calMoleculeNum([a, b, c], float(c1), float(c2), float(density)))
    tmp = input("Press Any Key to Stop")
